package Game.Items.Potions;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Vector2f;

import GUI.GuiManager;
import GUI.GuiMessenger;
import Game.Statistics;
import Game.Buff.BuffBase;
import Game.Items.GameItem;
import Game.Objects.GOPlayer;
import Game.Objects.Creatures.GOCreature;
import Screens.MyScreens.GameScreen;
import Tools.SoundManager;
import Tools.Drawing.FontTagSystem;

/** Antipoison Potion
 * Restores 5 HP
 * @author Aikidos
 */
public class GIAntipoisonPotion extends GameItem {
	
	public GIAntipoisonPotion() {
		super("Antipoison Potion");
		
		Category = ECategory.Potion;
		
		_isStackable = true;
		
		_cost = 40;
		_weight = 0.05f;
	}

	@Override
	public boolean use() throws SlickException {
		if (_ownerGameObject.isPlayer()) {
			GOPlayer player = (GOPlayer) _ownerGameObject;
			
			BuffBase debuffPoison = player.getBuffManager().getBuffByClass("Game.Buff.DebuffPoison");
			if (debuffPoison != null) player.getBuffManager().remove(debuffPoison);
			
			// Remove from unknown list
			Statistics.removeUnknownItem(this);
			
			GuiManager.getMessenger().addMessage("[green]You[/green] drank a [yellow]"
					+ getName() + "[/yellow]");
			
			// Play sound
			SoundManager.play("sfx_drink");
			
			return true;
		}
		
		if (_ownerGameObject.isCreature()) {
			GOCreature creature = (GOCreature) _ownerGameObject;

			BuffBase debuffPoison = creature.getBuffManager().getBuffByClass("Game.Buff.DebuffPoison");
			if (debuffPoison != null) creature.getBuffManager().remove(debuffPoison);
			else return false;
			
			return true;
		}
		
		return false;
	}
	
	@Override
	public void drawInfo(Vector2f drawPos, Graphics g) {
		
		if (Statistics.isUnknownItem(this)) {
			FontTagSystem.drawText("???", drawPos); return;
		}
		
		FontTagSystem.drawText("Description:", drawPos);
		
		drawPos.y += 20;
		
		FontTagSystem.drawText("Cures poison", drawPos);
	}
	
	@Override
	public String getName() {
		
		if (Statistics.getUnknownItems().contains(this.getClass().getName()))
			return "??? Potion";
		
		return super.getName();
	}
	
}
